/**
 * Created by Jay on 2016/10/9.
 */
function check_sub_card(){
    $("body").off();
    //详情
    $("body").on("click",".detail_list",function(e){
        console.log(e.target.dataset.id);
        mccmsa.goTo("answer_question_list_detail","answer_question_list_detail",{'this_id':e.target.dataset.id});
    })

    $("body").on("click",".push_delete",function(){
        var id=$(this).attr("data-id");
        delete_tips({
            url:"messageController/delReciveQuestion?id="+id,
            method:"get",
            content:"确认要删除？",
            data:{pageSize: 10, pageNo: 1},
            alert:"删除成功",
            alert_error:"删除失败"
        })
    })
    /*单个 删除S*/
    $("body").on("click",".push_delete",function(){
        var id=$(this).attr("data-id");
        console.log("id_+_single==="+id);
        delete_tips({
            url:"questionAnswerManageController/deleteQa",
            method:"POST",
            content:"确认要删除？",
            data:{'idStr':id},
            alert:"删除成功",
            alert_error:"删除失败"
        })
    })
    /*单个删除 E*/
    /*批量删除 S*/
    var judge_check=0;
    $("#del_all").on('click',function(){
        console.log("dededeedeedededededeedededededed");
        var del_list="";
        for(var i=1;i<$("input[type='checkbox']").length;i++){
            if($("input[type='checkbox']").eq(i).prop("checked")==true){
                judge_check=1;
                del_list+=$("input[type='checkbox']").eq(i).attr("data-id")+",";
            }
        }
        console.log("del_list_not_single"+del_list)
        if(judge_check==0){
            layer.alert("请选择需要删除的消息");
            return
        }
        console.log("del_list_+_+_+_+_+"+del_list);
        delete_tips({
            url:"questionAnswerManageController/deleteQa",
            method:"POST",
            content:"确认要批量删除？",
            data:{idStr:del_list},
            alert:"删除成功",
            alert_error:"删除失败"
        })
    })
    /*批量删除 E*/
    /* checkbox first 批量选择 S*/
    function click_all_change(){
        /*checkbox all s*/
        var check_all=1;
        $("#check_all").on("click",function() {
            var check=this.getAttribute("checked");
            if(!$("#check_all").prop("checked")){//如果 第一个checkbox 是已经点了的
                for(var i=0;i<$("input[type='checkbox']").length;i++){
                    $("input[type='checkbox']").eq(i).prop("checked",false)
                }
                return;
            }
            for(var i=0;i<$("input[type='checkbox']").length;i++){
                $("input[type='checkbox']").eq(i).prop("checked", true);
            }
        })
        /*checkbox all  E*/
    }
    /*check first 批量选择 E*/
    click_all_change();
    /*批量删除 S*/
    var judge_check=0;
    $("#del_all").on('click',function(){
        console.log("dededeedeedededededeedededededed");
        var del_list="";
        for(var i=1;i<$("input[type='checkbox']").length;i++){
            if($("input[type='checkbox']").eq(i).prop("checked")==true){
                judge_check=1;
                del_list+=$("input[type='checkbox']").eq(i).attr("data-id")+",";
            }
        }
        if(judge_check==0){
            layer.alert("请选择需要删除的消息");
            return
        }
        console.log("del_list_+_+_+_+_+"+del_list);
        delete_tips({
            url:opt.url,
            method:"POST",
            content:"确认要批量删除？",
            data:{ids:del_list},
            alert:"删除成功",
            alert_error:"删除失败"
        })
    })
    /*批量删除 E*/

    var this_id=$.bbq.getState("this_id");
   console.log("this_id__++_"+this_id);
    $.ajax({
        url:"questionAnswerManageController/checkChildNodes",
        type:"get",
        data:{
            "questionAnswerId":this_id,
            "pageNo":1,
            "pageSize":10
         },
        success:function(data){
        /*查看S*/
        $("body").on("click",".check_tip",function(e){
            mccmsa.goTo("check_sub_card","check_sub_card",{'this_id':e.target.dataset.id})
        })
        /*查看E*/
        /*删除S*/
        $("body").on("click",".delete_click",function(e){
                mccmsa.goTo("check_sub_card","check_sub_card",{'this_id':e.target.dataset.id})
        })
        /*删除E*/
        console.log("data");
        console.log(data);
        /*前边的 序号*/
            set_seqsum(
                {
                    pageNo: data.result.resultList.pageNo,
                    pageSize: data.result.resultList.pageSize
                }
            );
            create_page({
                url: "messageController/showAllReceiveQuestion",
                method: "get",
                data: data,
                temp: "getColumnTableData_push_mess",
                contain: "#ColumnTableData_push_mess",
                prePageSize: data.result.resultList.pageSize,
                prepageNo: data.result.resultList.pageNo
            })//生成分页
        mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器 都打成包了QAQ 是人不是。。
                templateId: "getColumnTableData_push_mess_sub_card_t",
                container: $("#ColumnTableData_push_mess_sub_card"),
                data: data,
                callback: function () {
                }
        })
        },error:function(e){
         console.log(e)
        }
    })
}